﻿using System;
using System.Collections.Generic;
using System.Text;

namespace MyLibrary.Logger
{
    /// <summary>
    /// 所有日写入类继承的公共接口
    /// </summary>
    /// <remarks>
    /// 该接口定义了日志写入类需要实现的公用方法:
    /// CloseLogWriter()
    /// DoLogWriter(LoggingEvent)
    /// 属性:
    /// LoggerName
    /// </remarks>
    public interface ILogWriter : IDisposable
    {
        delegate void LogWriteEventHandler(object caller);
        event LogWriteEventHandler OnLogWrite;
        /// <summary>
        /// LogWriter的名称
        /// </summary>
        string LogWriterName
        {
            get;
            set;
        }

        /// <summary>
        /// 配置
        /// </summary>
        Dictionary<string, string> ConfigCollection
        {
            get;
            set;
        }
        /// <summary>
        /// 写入日志
        /// </summary>
        /// <param name="loggingEvent">记录的日志事件</param>
        /// <param name="sendAlarm">是否发出警报</param>
        void DoLogWriter(LoggingEvent loggingEvent, bool sendAlarm);

        /// <summary>
        /// 关闭LogWriter,释放所有占用资源
        /// </summary>
        void CloseWriter();
    }

    public enum LogLevel
    {
        /// <summary>
        /// 仅写入日志
        /// </summary>
        LogOnly = 0,
        /// <summary>
        /// 仅进行报警
        /// </summary>
        AlarmOnly = 1,
        /// <summary>
        /// 写入日志并报警
        /// </summary>
        LogAndAlarm = 2,
    }

    /// <summary>
    /// 消息的格式
    /// </summary>
    public enum MessageFormat
    {
        /// <summary>
        /// 普通格式
        /// </summary>
        Simple = 0,
        /// <summary>
        /// XML格式
        /// </summary>
        XML = 1,
        /// <summary>
        /// 参数格式
        /// </summary>
        Partten = 2
    }
}
